<?
require( "Application.php");
$appManager = new AppManager();
$expectedKey = $appManager->getKey();
if($expectedKey != $_POST["keytest"])
echo "Key is not correct";
else {
	
	$storeVO = new StoreVO();
	$storeVO->name = $_POST["storeName"];
	$storeVO->address = $_POST["address"];
	$storeVO->city = $_POST["city"];
	$storeVO->state = $_POST["state"];
	$storeVO->zip = $_POST["zip"];
	$storeVO->lat = $_POST["lat"];
	$storeVO->lng = $_POST["lng"];
	$storeVO->phone = $_POST["phone"];
	$storeVO->website = $_POST["website"];
	$storeVO->email = $_POST["email"];
	$storeVO->twitter = $_POST["twitter"];
	$storeVO->yelpTerm = $_POST["searchterm"];
	$storeVO->facebook=$_POST["facebook"];
	$storeManager = new StoreManager();
	$storeId =  $storeManager->saveStore($storeVO);
	
	echo "Store INsert: " . $storeId . "<br>";
	echo "tag insert: " . $storeManager->saveStoreTag($storeId, $_POST["tagId"]);
	echo "include filter1: " . $storeManager->saveFilter($storeId, $_POST["include1"]);
	if(strlen($_POST["include2"]) > 1) {
		echo "include filter2: " . $storeManager->saveFilter($storeId, $_POST["include2"]);
	}else
	echo "No include2";
}
	
	
	
require( "OnRequestEnd.php"); 
?>